//
//  KRChatViewController.h
//  KingrayTone_ios
//
//  Created by XiongYingqi on 14-5-20.
//  Copyright (c) 2014年 XiongYingqi. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "UIBubbleTableViewDataSource.h"

@class XMPPUserCoreDataStorageObject;
@class UIBubbleTableView;
@protocol KRChatViewControllerDelegate;

//@class KRChatViewControllerDelegate;

@interface KRChatViewController : UIViewController <UIBubbleTableViewDataSource, NSFetchedResultsControllerDelegate> {
    float baseY;
    bool isShow;
    NSFetchedResultsController *fetchedResultsController;
}

@property(weak, nonatomic) XMPPUserCoreDataStorageObject *withUser;

/**
* 根据jid获取ChatRoomViewController，如果已经创建则返回实例，如果从未打开过则创建实例
*/
+ (id)getRoom:(XMPPUserCoreDataStorageObject *)withUser;

+ (NSMapTable *)chatRooms;

- (IBAction)editDidEnd:(id)sender;

@property(weak, nonatomic) IBOutlet UITextField *messageTextField;

//@property (weak, nonatomic) IBOutlet UITextField *messageTextField;
//@property(weak, nonatomic) IBOutlet UIScrollView *scrollView;
- (IBAction)sendMessage:(id)sender;

@property(weak, nonatomic) IBOutlet UIButton *sendMessageButton;

@property(weak, nonatomic) IBOutlet UIBubbleTableView *tableView;

- (IBAction)messageDidEnd:(id)sender;
- (IBAction)messageChanged:(id)sender;

+(void)setDelegate:(id <KRChatViewControllerDelegate>)targetDelegate;
- (NSFetchedResultsController *)fetchedResultsController;

//@property (weak, nonatomic) KRChatViewControllerDelegate *delegate;

/**
 * 聊天窗口的代理
 */
//@property(nonatomic, assign) IBOutlet id <KRChatViewControllerDelegate> delegate;


@end
